/*
	Pinkie's Balloon Fight
	Copyright (C) 2012  dancinninja (dancinninjac@gmail.com)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "Balloon.h"
#include "TexManager.h"

// How far the balloons follow the player
static const f32 BALLOON_FOLLOW_LAG = 128;

//----------------------------------------
// Default Constructor
//----------------------------------------

Balloon::Balloon(){
	x = 0;
	y = 0;
	width = 30;
	height = 40;
}

void Balloon::Render(){

	glBindTexture(GL_TEXTURE_2D, texture->obj);
	glLoadIdentity();
	
	glTranslatef(x+offsetx, y+offsety, -1);
	glScalef(width, height, 1);
	glColor4ub(255,255,255,255);

	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f);
		glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, 0.0f, 0.0f);
		glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 0.0f);
		glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 1.0f, 0.0f);
	glEnd();

}
//
void Balloon::FollowPoint(f32 pointx, f32 pointy){
	x += (pointx - x)/lagModifier; // It lags behind	the point
	y += (pointy - y)/lagModifier;
}
/*
void Balloon::SetPosition(f32 _x, f32 _y){
	x = _x;
	y = _y;
}

//*/
void Balloon::SetOffsets(f32 _offsetx, f32 _offsety){
	offsetx = _offsetx;
	offsety = _offsety;
}

void Balloon::SetLagMod(f32 mod){
	lagModifier = BALLOON_FOLLOW_LAG + mod;
}
